<template>
 <div>
   <div class="head">
    <el-row>
      <el-col :span="12" >
      </el-col>
        <el-col :span="10" :offset="1">
         <el-select  clearable @change="scarch()"  v-model="value">
            <el-option label="全部记录" value="0"></el-option>
            <el-option label="我的记录" value="1"></el-option>
        </el-select>
      </el-col>
    </el-row>
   </div>
    <!--  @row-click="handleCurrentChange1" 行点击事件 -->
   <el-table :data="pageInfo.list" class="tb-edit" highlight-current-row style="width: 100%">  
    <el-table-column prop="id"  label="序号"  width="80"></el-table-column>
    <!-- <el-table-column prop="uid"  label="评论人"  width="80"></el-table-column> -->
    <el-table-column prop="uname"   label="评论人"  width="120"></el-table-column>
    <el-table-column prop="vid"  label="评论作品"  width="100"></el-table-column>
    <el-table-column prop="parentId"  label="父评论"  width="100"></el-table-column>
    <!-- <el-table-column prop="replyId"  label=""  width="120"></el-table-column> -->
    <el-table-column prop="replyName"  label="被回复人"  width="120"></el-table-column>
    <el-table-column prop="commentLevel"  label="评论级别"  width="120">
      <template slot-scope="scope">
　　　　 　<span v-if="scope.row.commentLevel== '1'">作品评论</span>
　　　　 　<span v-if="scope.row.commentLevel== '2'">其他评论</span>
　　　　</template>
    </el-table-column>
    <el-table-column prop="content"  show-overflow-tooltip label="评论内容"  width="120"> </el-table-column>
    <el-table-column prop="stateTop"  label="是否置顶"   width="120">
      <!-- <template slot-scope="scope">
		   <el-select v-model="scope.row.stateTop"   @focus="getDatalist(scope.row)"  placeholder="请选择" filterable allow-create>
			  <el-option  :value="0" label="否"></el-option>
              <el-option  :value="1" label="是"></el-option>
			</el-select>
		</template> -->
        <template slot-scope="scope">
　　　　 　<span v-if="scope.row.stateTop== 0">否</span>
　　　　 　<span v-if="scope.row.stateTop== 1">是</span>
　　　　</template>
    </el-table-column>
    <el-table-column prop="createTime"  label="评论时间"  show-overflow-tooltip width="120"></el-table-column>
    <el-table-column prop="state"  label="评论是否违规"   width="120">
        <!-- <template slot-scope="scope">
		   <el-select v-model="scope.row.state"   @focus="getDatalist(scope.row)"  placeholder="请选择" filterable allow-create>
            <el-option  :value="0" label="待审核"></el-option>
            <el-option  :value="1" label="否"></el-option>
            <el-option  :value="2" label="是"></el-option>
			</el-select>
		</template> -->
        <template slot-scope="scope">
　　　　 　<span v-if="scope.row.state== 1">否</span>
　　　　 　<span v-if="scope.row.state== 2">是</span>
　　　　</template>
    </el-table-column>
    <!-- <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="small" type="danger" @click="edit(scope.$index, scope.row)">保存</el-button>
      </template>
    </el-table-column> -->
  </el-table>
   
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-count="pageInfo.pages"
      :current-page="pageNum"
      :page-sizes="limits"
      :page-size="pageSize"
      layout="total,sizes, prev, pager, next"
      >
      <!--  -->
    </el-pagination>
    <!-- 表单 -->

 </div>
</template>

<script>
  export default {
    
    data() {
      return {
      loading:true,
        roles:[],
        pageInfo: {
          list:[],
        },form: {},
        dialog:false,
        dialogFormVisible:false,
        input:'',
        formLabelWidth: '120px',
        limits:[3, 5, 7],
        pageSize:7,// limits 的第几条
        pageNum:1,// 第几页
        action:'',
        value:""
       
      }
    },
    created(){
      this.scarch();
    },
    methods: {
            //  handleCurrentChange1(row, event, column) {
            //     console.log(row, event, column, event.currentTarget)
            // },

             edit(index, row) {
               console.log("row1----",row);
               let authUser=this.$qs.parse(sessionStorage.getItem("authUser"))
               row.auditor=authUser.uid
               console.log("row2---",row)
               if(row.state==0){
                 this.$message({message:"没有完成审核",type:"warning"})
               }else{
                  this.$http.get("/comment/updateState",{params:{...row}}).then(res=>{
                    if(res){
                      this.$message({message:"保存成功",type:"success"})
                      this.scarch()
                    }else{
                        this.$message({message:"保存失败",type:"error"})
                        this.scarch()
                    }
                  })
               }
            },
        
      getDatalist(row){
          console.log(row)
      },
      scarch(){
        
          if(this.value=="0"||this.value==""){
              console.log("quanbu",this.value)
            this.$http.get('/comment/commentRecord', {params: {pageNum: this.pageNum,pageSize:this.pageSize,value:this.value}}).then(res=>{
            this.pageInfo=res
            })
          }else{
               console.log(this.value)
              let authUser=this.$qs.parse(sessionStorage.getItem("authUser"))
              this.$http.get('/comment/commentRecord', {params: {pageNum: this.pageNum,pageSize:this.pageSize,value:authUser.uid}}).then(res=>{
                this.pageInfo=res
              })
          }    
      },handleSizeChange(a){
        this.pageSize=a
        this.scarch();
      },handleCurrentChange(a){       
          this.pageNum=a
        this.scarch();
      }
      
    }
  }
</script>
<style scoped>
 .head{
   padding: 10px 5px;
 }
 

</style>
<style  scoped>
 .tb-edit .el-input {
    display: none
}
.tb-edit .current-row .el-input {
    display: block
}
.tb-edit .current-row .el-input+span {
    display: none
}
</style>
